# Vito D'Orazio
# September 8, 2020
# views1.py

# this script loads views data and writes csv files for analysis

import views

# Show available datasets
print(list(views.DATASETS.keys()))

# Select cm africa
dataset = views.DATASETS["cm_africa_imp_0"]

# Get the usable dataframe.
# This will take a while as the data is assembled.
df = dataset.df

df.to_csv('/Users/vjdorazio/PycharmProjects/views/data072820/cm_africa.csv')

# Select pgm africa
dataset = views.DATASETS["pgm_africa_imp_0"]

# Get the usable dataframe.
# This will take a while as the data is assembled.
df = dataset.df

df = df.loc[(df['year']<=2005)]

df.to_csv('/Users/vjdorazio/PycharmProjects/views/data072820/pgm_africa_leq2005.csv')

# Select pgm africa
dataset = views.DATASETS["pgm_africa_imp_0"]

# Get the usable dataframe.
# This will take a while as the data is assembled.
df = dataset.df

df = df.loc[(df['year']>2005)]

df.to_csv('/Users/vjdorazio/PycharmProjects/views/data072820/pgm_africa_gt2005.csv')


dataset = views.DATASETS["pgm_africa_imp_0"]

# Get the usable dataframe.
# This will take a while as the data is assembled.
df = dataset.df

# pg_id and month_id are not columns in the data frame but are printed with to_csv
df = df[['ged_best_sb']]

df.to_csv('/Users/vjdorazio/PycharmProjects/views/data072820/pgm_africa_dvsub.csv')
